Skip to content

Bytes: Fix length from fromBytes on JS#2025

Merged
joshtynjala merged 4 commits intoopenfl:developfrom
Geokureli:patch-1
Feb 6, 2026
Merged

Bytes: Fix length from fromBytes on JS#2025
joshtynjala merged 4 commits intoopenfl:developfrom
Geokureli:patch-1

Conversation

@Geokureli
Copy link
Contributor

@Geokureli Geokureli commented Jan 25, 2026

Potentially related to: openfl/openfl#2360

In JS the underlying byte data may have extras, due to the underlying types used in js, explained here: HaxeFoundation/haxe#8974. This pr will ignore those extras.

Example reproducing the inconsistent behavior:

final output = new haxe.io.BytesOutput();
output.writeString("test");
final byteArray = lime.utils.Bytes.fromBytes(output.getBytes());
trace('byteArray.length: ${byteArray.length}'); // 16 on JS, 4 otherwise

Tested on chrome for mac

@player-03
Copy link
Contributor

Tested on chrome for mac

I also got 16 in Firefox on Linux.

@Geokureli
Copy link
Contributor Author

I also added a fix to haxe, but lime should probably account for this on older versions

joshtynjala added a commit to openfl/openfl that referenced this pull request Feb 6, 2026
It turns out that the underlying ArrayBuffer might be longer than the ByteArray, so make a copy in that case because TextDecoder strictly reads the entire ArrayBuffer (references openfl/lime#2025).

Followup to commit dcf3f11
@joshtynjala joshtynjala merged commit 8d744dd into openfl:develop Feb 6, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants